package com.sj.uabrowser.mvp.main.view.act;

import android.Manifest;
import android.content.Intent;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;

import com.sj.uabrowser.MainActivity;
import com.sj.uabrowser.R;
import com.sj.uabrowser.app.StatusBarUtil;
import com.sj.uabrowser.framework.BaseActivity;
import com.sj.uabrowser.framework.BasePresenter;

public class SplashAct extends BaseActivity {


    @Override
    public BasePresenter createPresenter() {
        return null;
    }

    @Override
    public int getLayoutID() {
        return R.layout.activity_splash;
    }

    @Override
    public void setView() {
        if (!this.isTaskRoot()) {
            Intent mainIntent = getIntent();
            String action = mainIntent.getAction();
            if (mainIntent.hasCategory(Intent.CATEGORY_LAUNCHER) && Intent.ACTION_MAIN.equals(action)) {
                finish();
                return;
            }
        }
        StatusBarUtil.setTransparentForImageViewInFragment(this,null);
        statusbar.setVisibility(View.GONE);
    }

    @Override
    public void setData() {
        rxPermissions.request(Manifest.permission.ACCESS_FINE_LOCATION)
                .subscribe(grant->{
                    new Handler().postDelayed(new Runnable() {
                        @Override
                        public void run() {
                            startActivity(new Intent(SplashAct.this, MainActivity.class));
                            finish();
                        }
                    },1000);
                });

    }
}
